<template>
    <div>
      <div style="padding: 5px 10px">
        <h3>课题基本信息</h3>
        <table class="bs-table">
          <tr class="bs-table_row">
            <th class="bs-table_th" style="width: 200px">规划名称</th>
            <td class="bs-table_td" colspan="3">
              <el-link :href="publicPath+'/#/planning/achievement/detail?id='+ detaildata.achievementId" target="_blank" style="font-size: 18px;font-weight: bold">{{detaildata.achievementTitle}}</el-link>
              <span>【{{detaildata.pmuc}}】</span>
            </td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th" style="width: 200px">课题名称</th>
            <td class="bs-table_td" colspan="3">{{detaildata.title}}</td>
          </tr>
          <tr class="bs-table_row" style="width: 200px">
            <th class="bs-table_th">责任部门</th>
            <td class="bs-table_td">{{detaildata.deptName}}</td>
            <th class="bs-table_th" style="width: 200px">配合部门</th>
            <td class="bs-table_td">{{detaildata.supportDeptName}}</td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th">课题概述</th>
            <td class="bs-table_td" colspan="3">{{detaildata.description}}</td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th">课题报告</th>
            <td class="bs-table_td" colspan="3">
              <span v-if="resultFileList.length>=1">
                <preview :attachementId="detaildata.resultFileList[0].fileId" v-if="detaildata.resultFileList[0].fileId"></preview>
              </span>
            </td>
          </tr>
          <tr class="bs-table_row">
            <th class="bs-table_th">创建时间</th>
            <td class="bs-table_td">{{detaildata.createTime}}</td>
            <th class="bs-table_th">列入编制时间</th>
            <td class="bs-table_td">{{detaildata.joinTime}}</td>
          </tr>
        </table>
      </div>
      <div style="padding: 5px 10px">
        <h3>成果报告信息</h3>
        <table class="bs-table">
          <tr class="bs-table_row">
            <th class="bs-table_th">报告名称</th>
            <th class="bs-table_th">修改说明</th>
            <th class="bs-table_th">上传人</th>
            <th class="bs-table_th">上传时间</th>
            <th class="bs-table_th">操作</th>
          </tr>
          <tr class="bs-table_row" v-for="(resultFile,index) in resultFileList" :key="index">
            <th class="bs-table_td">{{resultFile.fileFullName}}</th>
            <th class="bs-table_td">{{resultFile.updateReason}}</th>
            <th class="bs-table_td">{{resultFile.uploadNickname}}</th>
            <th class="bs-table_td">{{resultFile.uploadTime}}</th>
            <th class="bs-table_td">
              <el-link :href="'/planning/file/download/'+resultFile.fileId">下载</el-link>
            </th>
          </tr>
        </table>
      </div>
      <div style="padding: 5px 10px" v-if="detaildata.showProcess">
        <h3>课题进度信息</h3>
        <!--<el-timeline :reverse="reverse">-->
        <el-timeline>
          <el-timeline-item
            :timestamp="detaildata.createTime">
            拟定课题
          </el-timeline-item>
          <el-timeline-item
            :timestamp="detaildata.joinTime">
            编制计划
          </el-timeline-item>
          <el-timeline-item
            :timestamp="detaildata.researchTime">
           课题研究
          </el-timeline-item>
          <el-timeline-item
            :timestamp="detaildata.publishTime">
            课题结题
          </el-timeline-item>
        </el-timeline>
      </div>
      <div style="padding: 5px 10px">
        <h3>相关材料信息</h3>
        <table class="bs-table" >
          <tr class="bs-table_row">
            <th class="bs-table_th">文件名称</th>
            <th class="bs-table_th">内容</th>
            <th class="bs-table_th">上传人</th>
            <th class="bs-table_th">上传时间</th>
            <th class="bs-table_th">操作</th>
          </tr>
          <tr class="bs-table_row" v-for="(fileObject,index) in fileList" :key="index">
            <th class="bs-table_td">{{fileObject.fileName}}</th>
            <th class="bs-table_td">{{fileObject.updateReason}}</th>
            <th class="bs-table_td">{{fileObject.uploadNickname}}</th>
            <th class="bs-table_td">{{fileObject.uploadTime}}</th>
            <th class="bs-table_td">
              <el-link :href="'/planning/file/download/'+fileObject.fileId">下载</el-link>
            </th>
          </tr>
          <tr class="bs-table_row" v-if="!fileList || fileList.length == 0">
            <th class="bs-table_td"  colspan="5">
              暂无数据
            </th>
          </tr>
        </table>
      </div>
    </div>
</template>

<script>
  import {getSubjectDetail} from "@/api/subject";
  import {filedownload} from "@/api/system";

  export default {
    name: "subjectDetail",
    props: {
      id: Number
    },
    created() {
      this.getSubjectDetailData();
    },
    computed: {
    },
    data() {
      return {
        headerData: {
          title: '课题详细信息'
        },
        detaildata:{},
        resultFileList:[],
        fileList:[],
        publicPath:process.env.VUE_APP_PUBLIC_PATH
      }
    },
    methods: {
      getSubjectDetailData(){
        getSubjectDetail(this.id).then(response => {
          if (response.data.code == 0) {
            if (response.data.data.length != 0) {
              this.detaildata  = response.data.data
              if(response.data.data && response.data.data.resultFileList){
                this.resultFileList =response.data.data.resultFileList

              }
              if(response.data.data && response.data.data.fileList){
                this.fileList =response.data.data.fileList

              }
            }

          }
        });
      },
      goBack() {
        this.$router.go(-1);
      }
    }
  }
</script>

<style ang="scss" scoped>

</style>
